{include file="common/top" /}
 <link  type="text/css" href="__static/ossupload/style.css"/>
<style>
html{
	background: #ffffff;
}
</style>
<form class="layui-form " action="" style="background: #fff;">
	<div class="layui-form-item">
		<label class="layui-form-label">充值编号：</label>
		<div class="layui-col-xs4">
			<input type="text" readonly="readonly" name="code" value="{$rs.code}" lay-verify="required" autocomplete="off" class="layui-input">
		</div>
		<label class="layui-form-label">客户姓名：</label>
		<div class="layui-col-xs4">
			<select name="customer_id" lay-verify="required" lay-search=""  lay-verify="required" autocomplete="off">
				<option value="">直接选择或搜索选择</option>
				{volist name="customer" id='cu'}
					<option value="{$cu.id}" {eq name="rs.customer_id" value="$cu.id"}selected{/eq}>{$cu.name}</option>
				{/volist}
	        </select>
		</div>
	</div>
	<div class="layui-form-item">
		<label class="layui-form-label">公司卡号：</label>
		<div class="layui-col-xs4">
			<select name="account_bank_id" lay-verify="required" lay-search=""  lay-verify="required" autocomplete="off">
				<option value="">直接选择或搜索选择</option>
				{volist name="account_list" id='acc'}
					<option value="{$acc.id}" {eq name="rs.account_bank_id" value="$acc.id"}selected{/eq}>{:$acc["type"]==1?'对公':'对私'}，{$acc.num}</option>
				{/volist}
	        </select>
		</div>
		<label class="layui-form-label">打款金额：</label>
		<div class="layui-col-xs4">
			<input type="text" name="amount" value="{$rs.amount}" lay-verify="required" autocomplete="off" placeholder="请输入充值金额" class="layui-input">
		</div>
	</div>
	<div class="layui-form-item">
		<label class="layui-form-label">打款时间：</label>
		<div class="layui-col-xs4">
			<input type="text" name="create_time" value="{:date('Y-m-d H:i:s',$rs['create_time'])}" id="date" lay-verify="datetime" placeholder="yyyy-MM-dd" autocomplete="off" class="layui-input">
		</div>
		<label class="layui-form-label">媒介：</label>
		<div class="layui-col-xs4">
			<select name="media_id" lay-verify="required" lay-search=""  autocomplete="off">
				<option value="">直接选择或搜索选择</option>
				{volist name="user_list" id='user'}
					<option value="{$user.id}" {eq name="rs.media_id" value="$user.id"}selected{/eq}>{$user.username}</option>
				{/volist}
	        </select>
		</div>
	</div>
	
	<div class="layui-form-item">
        <label class="layui-form-label">上传凭证：</label>
        <div class="layui-col-xs4">
            <div class="layui-upload-drag" id="test10">
                  <i class="layui-icon"></i>
                  <p>点击上传，或将文件拖拽到此处</p>
                  <div class="layui-hide" id="uploadDemoView">
                      <hr>
                    <img src="{$rs.screenshot_url}" alt="上传成功后渲染" style="max-width: 196px">
                  </div>
            </div>
        </div>
        
    </div>
	<div class="layui-form-item">
		<label class="layui-form-label">备注：</label>
		<div class="layui-col-xs9">
			<textarea name="note" autocomplete="off" placeholder="请输入详细备注" class="layui-textarea">{$rs.note}</textarea>
		</div>
	</div>
	<hr />
	<div class="layui-form-item">
		<div class="layui-input-block">
			<input type="hidden" id='image'  name="screenshot_url" value="{$rs.screenshot_url}">
			<input type="hidden"  name="id" value="{$rs.id}">
			<button class="layui-btn"  lay-submit="" lay-filter="demo1">修改</button>
		</div>
	</div>
	
</form>
{include file="common/footer" /}
<script>
	layui.use(['form', 'layedit', 'laydate','upload'], function(){
		
		  var form = layui.form ,layer = layui.layer,laydate = layui.laydate,$ = layui.jquery,upload = layui.upload;
		  laydate.render({
			    elem: '#date', //指定元素
			    type: 'datetime',
			  });
		  //监听提交
		  form.on('submit(demo1)', function(data){
			var articleFrom = data.field;
			layer.load(1, { shade : [ 0.5, '#676a6c' ] }); 
			$.post("{:url('save_recharge')}?t=json",articleFrom,function(data){
				layer.closeAll();
				if (data['code'] == 1) { 
					var index1 = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
					parent.layer.close(index1); //再执行关闭 
					//父页面数据 ，重新加载
					parent.get_s(data['msg']);

				} else {
					layer.msg(data['msg'], { icon : 5 });
				}
			});
			
			return false;
		  });
		//拖拽上传
		upload.render({
		    elem: '#test10'
		    ,url: '{:url("Upload/index")}' //改成您自己的上传接口
		    ,exts: 'jpg|png|jpeg|gif'
	    	,choose: function(obj){
	    		layer.load(1, { shade : [ 0.5, '#676a6c' ] });
	    	}
		    ,done: function(res){
		    	layer.closeAll();
		    	if(res.code == 0){
		    		layer.msg('上传成功');
				    layui.$('#uploadDemoView').removeClass('layui-hide').find('img').attr('src', res.data);
				    $("input[name=screenshot_url]").val(res.data);
		    	}else{
		    		layer.msg(res.msg);
		    	}
		      
		      //console.log(res)
		    }
		});  
		//监听指定开关
		  form.on('switch(switchTest)', function(data){
			  if(this.checked){
				  $("input[name=is_advance]").val(1);
			  }else{
				  $("input[name=is_advance]").val(0);
			  }
		  });
		//点击查看图片
		  layer.photos({
			  photos: '#imgspan'
			  ,anim: 5 //0-6的选择，指定弹出图片动画类型，默认随机（请注意，3.0之前的版本用shift参数）
			});
		 
		});
	
</script>
